cmake_minimum_required(VERSION 3.13.0)
project(common CXX)

set(CMAKE_CXX_STANDARD 14)


SET(CMAKE_BUILD_TYPE "Debug")
SET(CMAKE_CXX_FLAGS_DEBUG "$ENV{CXXFLAGS} -O0 -Wall -g2 -ggdb")
SET(CMAKE_CXX_FLAGS_RELEASE "$ENV{CXXFLAGS} -O3 -Wall")


find_package(glog REQUIRED)
find_package(Eigen3 REQUIRED)
find_package(osqp REQUIRED)
find_package(PythonLibs REQUIRED)


add_executable(spile2d_test osqp_spline2d_solver_test.cc 
src/common/smoothing/affine_constraint.cc
src/common/smoothing/discrete_points_math.cc
src/common/smoothing/osqp_spline1d_solver.cc
src/common/smoothing/osqp_spline2d_solver.cc
src/common/smoothing/polynomialxd.cc
src/common/smoothing/spline1d_constraint.cc
src/common/smoothing/spline1d_kernel_helper.cc
src/common/smoothing/spline1d_kernel.cc
src/common/smoothing/spline1d_seg.cc
src/common/smoothing/spline1d.cc
src/common/smoothing/spline2d_constraint.cc
src/common/smoothing/spline2d_kernel.cc
src/common/smoothing/spline2d_seg
src/common/smoothing/spline2d.cc
src/common/utils/math.cc
src/common/solver/osqp/osqp_interface.cc
)

add_executable(spile1d_test osqp_spline1d_solver_test.cc 
src/common/smoothing/affine_constraint.cc
src/common/smoothing/discrete_points_math.cc
src/common/smoothing/osqp_spline1d_solver.cc
src/common/smoothing/osqp_spline2d_solver.cc
src/common/smoothing/polynomialxd.cc
src/common/smoothing/spline1d_constraint.cc
src/common/smoothing/spline1d_kernel_helper.cc
src/common/smoothing/spline1d_kernel.cc
src/common/smoothing/spline1d_seg.cc
src/common/smoothing/spline1d.cc
src/common/smoothing/spline2d_constraint.cc
src/common/smoothing/spline2d_kernel.cc
src/common/smoothing/spline2d_seg
src/common/smoothing/spline2d.cc
src/common/utils/math.cc
src/common/solver/osqp/osqp_interface.cc
)

add_executable(matplot_test matplot_test.cc)

include_directories(SYSTEM ${EIGEN3_INCLUDE_DIR})
include_directories(${CMAKE_SOURCE_DIR}/src)
include_directories(${PYTHON_INCLUDE_DIRS})

target_link_libraries(spile2d_test 
  ${PYTHON_LIBRARIES}
  osqp::osqp
  glog
)
target_link_libraries(spile1d_test 
  ${PYTHON_LIBRARIES}
  osqp::osqp
  glog
)

target_link_libraries(matplot_test 
  ${PYTHON_LIBRARIES}
)